import{ useRef } from 'react';

export default function UncontrolledInput() {
    const inputRef = useRef<HTMLInputElement>(null);

    const handleSubmit = (event: React.FormEvent) => {
        event.preventDefault();
        if (inputRef.current) {
            alert(`输入的值: ${inputRef.current.value}`);
        }
    };

    return (
        <form onSubmit={handleSubmit}>
            <input type="text" defaultValue="初始值" ref={inputRef} />
            <button type="submit">提交</button>
        </form>
    );
}
